/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package pojos;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author A7med Kotb
 */
@Entity
@Table(name = "exporter")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Exporter.findAll", query = "SELECT e FROM Exporter e"),
    @NamedQuery(name = "Exporter.findByIdExporter", query = "SELECT e FROM Exporter e WHERE e.idExporter = :idExporter"),
    @NamedQuery(name = "Exporter.findByExporterName", query = "SELECT e FROM Exporter e WHERE e.exporterName = :exporterName"),
    @NamedQuery(name = "Exporter.findByCountry", query = "SELECT e FROM Exporter e WHERE e.country = :country"),
    @NamedQuery(name = "Exporter.findByPhone", query = "SELECT e FROM Exporter e WHERE e.phone = :phone"),
    @NamedQuery(name = "Exporter.findByExporterCode", query = "SELECT e FROM Exporter e WHERE e.exporterCode = :exporterCode"),
    @NamedQuery(name = "Exporter.findByOther", query = "SELECT e FROM Exporter e WHERE e.other = :other"),
    @NamedQuery(name = "Exporter.findByBalance", query = "SELECT e FROM Exporter e WHERE e.balance = :balance")})
public class Exporter implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @NotNull
    @Column(name = "idExporter")
    private Integer idExporter;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 45)
    @Column(name = "exporterName")
    private String exporterName;
    @Size(max = 45)
    @Column(name = "country")
    private String country;
    // @Pattern(regexp="^\\(?(\\d{3})\\)?[- ]?(\\d{3})[- ]?(\\d{4})$", message="Invalid phone/fax format, should be as xxx-xxx-xxxx")//if the field contains phone or fax number consider using this annotation to enforce field validation
    @Size(max = 45)
    @Column(name = "phone")
    private String phone;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 45)
    @Column(name = "exporterCode")
    private String exporterCode;
    @Size(max = 45)
    @Column(name = "other")
    private String other;
    // @Max(value=?)  @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
    @Column(name = "balance")
    private Double balance;
    @OneToMany(mappedBy = "exporterID")
    private Collection<ExporterItem> exporterItemCollection;
    @OneToMany(mappedBy = "exporterID")
    private Collection<Bill> billCollection;

    public Exporter() {
    }

    public Exporter(Integer idExporter) {
        this.idExporter = idExporter;
    }

    public Exporter(Integer idExporter, String exporterName, String exporterCode) {
        this.idExporter = idExporter;
        this.exporterName = exporterName;
        this.exporterCode = exporterCode;
    }

    public Integer getIdExporter() {
        return idExporter;
    }

    public void setIdExporter(Integer idExporter) {
        this.idExporter = idExporter;
    }

    public String getExporterName() {
        return exporterName;
    }

    public void setExporterName(String exporterName) {
        this.exporterName = exporterName;
    }

    public String getCountry() {
        return country;
    }

    public void setCountry(String country) {
        this.country = country;
    }

    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    public String getExporterCode() {
        return exporterCode;
    }

    public void setExporterCode(String exporterCode) {
        this.exporterCode = exporterCode;
    }

    public String getOther() {
        return other;
    }

    public void setOther(String other) {
        this.other = other;
    }

    public Double getBalance() {
        return balance;
    }

    public void setBalance(Double balance) {
        this.balance = balance;
    }

    @XmlTransient
    public Collection<ExporterItem> getExporterItemCollection() {
        return exporterItemCollection;
    }

    public void setExporterItemCollection(Collection<ExporterItem> exporterItemCollection) {
        this.exporterItemCollection = exporterItemCollection;
    }

    @XmlTransient
    public Collection<Bill> getBillCollection() {
        return billCollection;
    }

    public void setBillCollection(Collection<Bill> billCollection) {
        this.billCollection = billCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idExporter != null ? idExporter.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Exporter)) {
            return false;
        }
        Exporter other = (Exporter) object;
        if ((this.idExporter == null && other.idExporter != null) || (this.idExporter != null && !this.idExporter.equals(other.idExporter))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "beans.Exporter[ idExporter=" + idExporter + " ]";
    }
    
}
